home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / THINKC / 3_0 / DOUBLEDE / ABOUT.C next >
Text File  |  1988-07-28  |  2KB  |  100 lines

  1. /*====================================================================
  2.  
  3.     about.c
  4.     
  5.     a general About... routine which displays a window giving credit
  6.     to the author, version number, and copyright notice.
  7.     
  8.     sample calling procedure...
  9.     ....
  10.     doabout("My Application","Version Number");
  11.     
  12. ====================================================================*/
  13.  
  14. #include <WindowMgr.h>
  15. #include <EventMgr.h>
  16. #include <TextEdit.h>
  17.  
  18. #define            COPYRIGHT        "Copyright ⌐ 1988 by Galen Babcock"
  19.  
  20. doabout(titleStr,versionStr)
  21. char    *titleStr;
  22. char    *versionStr;
  23. {
  24.     Rect        r;
  25.     WindowPtr    w;
  26.     Str255        about_utilStr;
  27.     
  28.     /*
  29.         create the About... window
  30.     */
  31.     SetRect(&r,0,0,350,120);
  32.     SetPort(w=NewWindow(0L,&r,"\p",FALSE,3,-1L,FALSE,0L));
  33.     TextFont(0);
  34.     TextSize(12);
  35.     TextFace(condense);
  36.     centerwindow(w,&screenBits.bounds);
  37.     ShowWindow(w);
  38.     
  39.     /*
  40.         calculate rectangle for application title, and draw the
  41.         text using TextBox
  42.     */
  43.     r = w->portRect;
  44.     r.top += 15;
  45.     r.bottom = r.top + 15;
  46.     TextBox(titleStr,strlen(titleStr),&r,teJustCenter);
  47.  
  48.     /*
  49.         change fonts, offset rect for author credit, and
  50.         draw with TextBox
  51.     */
  52.     TextFont(3);
  53.     TextSize(9);
  54.     TextFace(0);
  55.     strcpy(about_utilStr,"by Galen Babcock");
  56.     OffsetRect(&r,0,15);
  57.     TextBox(about_utilStr,strlen(about_utilStr),&r,teJustCenter);
  58.     
  59.     /*
  60.         give THINK the required credit
  61.     */
  62.     OffsetRect(&r,0,18);
  63.     r.bottom = r.top + 60;
  64.     strcpy(about_utilStr,"Written & Compiled with LightspeedC 2.15...\r therefore ");
  65.     strcat(about_utilStr,"portions Copyright ⌐ 1986,1987 by THINK Technologies, Inc.");
  66.     TextBox(about_utilStr,strlen(about_utilStr),&r,teJustCenter);
  67.     
  68.     /*
  69.         calculate position of copyright notice (lower left corner),
  70.         and draw the C string
  71.     */
  72.     r = w->portRect;
  73.     MoveTo(r.left+4,r.bottom-4);
  74.     DrawText(COPYRIGHT,0,strlen(COPYRIGHT));
  75.  
  76.     /*
  77.         take version number passed in parameter, add "Version "
  78.         to front of it, calculate the position to draw it 
  79.         (lower right corner) and draw the C string
  80.     */
  81.     strcpy(about_utilStr,"Version ");
  82.     strcat(about_utilStr,versionStr);
  83.     MoveTo(r.right-4-TextWidth(about_utilStr,0,strlen(about_utilStr)),r.bottom-4);
  84.     DrawText(about_utilStr,0,strlen(about_utilStr));
  85.  
  86.     /*
  87.         wait for a mouse click....
  88.     */
  89.     while(Button());
  90.     while(!Button());
  91.     while(Button());
  92.  
  93.     FlushEvents(mDownMask,0);
  94.     /*
  95.         dispose everything and return
  96.     */
  97.     HideWindow(w);
  98.     DisposeWindow(w);
  99.  
  100. }